package com.htgd.gardenexpo.enums;

/**
 * @author: 王秀田
 * @date: 2024/11/11 9:35
 * @description: 座位排列类
 */
public class SeatArrangement {

    private Seat[][] seats;

    public SeatArrangement(int rows, int columns) {
        seats = new Seat[rows][columns];
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < columns; j++) {
                seats[i][j] = new Seat(SeatStatus.AVAILABLE);
            }
        }
    }

    public void setSeatStatus(int row, int column, SeatStatus status) {
        if (row >= 0 && row < seats.length && column >= 0 && column < seats[row].length) {
            seats[row][column].setStatus(status);
        }
    }

    public SeatStatus getSeatStatus(int row, int column) {
        if (row >= 0 && row < seats.length && column >= 0 && column < seats[row].length) {
            return seats[row][column].getStatus();
        }
        return null;
    }

    public static void main(String[] args) {
        //创建10排15列
        SeatArrangement seatArrangement = new SeatArrangement(10, 15);
        //设置2排5列已选
        seatArrangement.setSeatStatus(2, 5, SeatStatus.AVAILABLE);
        SeatStatus seatStatus = seatArrangement.getSeatStatus(2, 5);
        System.out.println("座位2排5列: " + seatStatus);
    }
}
